package com.example.mybatis.plugin;

/**
 * 抽象化类，实现对应的抽象化的拦截器一些方法
 */
public abstract class AbstractInterceptor implements Interceptor {
    @Override
    public Object intercept(Invocation invocation) throws Exception {
        before(invocation);

        Object result = invocation.process();

        after(invocation, result);
        return result;
    }

    /**
     * 后置拦截
     *
     * @param invocation
     * @param result
     */
    abstract void after(Invocation invocation, Object result);

    /**
     * 前置拦截
     *
     * @param invocation
     */
    abstract void before(Invocation invocation);
}
